-
Notifications
You must be signed in to change notification settings - Fork 60
fix(op-acceptor): add build dependencies and increase logs #352
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Do you still think this is needed? |
1dbbcec
to
f588c27
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #352 +/- ##
==========================================
+ Coverage 55.48% 55.66% +0.17%
==========================================
Files 75 75
Lines 9591 9646 +55
==========================================
+ Hits 5322 5369 +47
- Misses 3913 3920 +7
- Partials 356 357 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
# Set ownership of the /app directory to allow the application to write logs and other files at runtime | ||
RUN chown -R app:app /app/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this needed? The logs and files are working without this, I believe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is needed if running the docker image locally unless we change the directory we run it on (like in CI).
// Check if the path is available locally | ||
if isLocalPath(metadata.Package) { | ||
fullPath := filepath.Join(r.workDir, metadata.Package) | ||
if _, statErr := os.Stat(fullPath); os.IsNotExist(statErr) { | ||
r.log.Error("Local package path does not exist, failing test", "validator", metadata.ID, "package", metadata.Package, "fullPath", fullPath) | ||
return &types.TestResult{ | ||
Metadata: metadata, | ||
Status: types.TestStatusFail, | ||
Error: fmt.Errorf("local package path does not exist: %s", fullPath), | ||
}, nil | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't been able to find any evidence that this is needed.
I believe Go can and will resolve local paths, even when referenced as their full package paths.
Are you sure it's needed? How?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without this part if you have a test that uses a local path in 'package' and this path doesn't exist then the entire test suite will fail and it may not be obvious why.
We're using such paths in our test file so this would be relevant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I follow, can you give me an example?
// Check if the path is available locally | ||
if isLocalPath(metadata.Package) { | ||
fullPath := filepath.Join(r.workDir, metadata.Package) | ||
if _, statErr := os.Stat(fullPath); os.IsNotExist(statErr) { | ||
r.log.Error("Local package path does not exist, failing test", "validator", metadata.ID, "package", metadata.Package, "fullPath", fullPath) | ||
return &types.TestResult{ | ||
Metadata: metadata, | ||
Status: types.TestStatusFail, | ||
Error: fmt.Errorf("local package path does not exist: %s", fullPath), | ||
}, nil | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't been able to find any evidence that this is required. My understanding, and experience, suggest that it's not because Go finds local packages (even when referenced by their full package paths).
Are you sure it's needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a comment above relating this, the tldr is that without this entry if you have a test that uses a local path in 'package' and this path doesn't exist then the entire test suite will fail.
We're using such paths in our test file so this would be relevant.
op-acceptor/runner/runner.go
Outdated
// Always set the LOG_LEVEL environment variable | ||
runEnv := append([]string{fmt.Sprintf("LOG_LEVEL=%s", r.testLogLevel)}, os.Environ()...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this supposed to be TEST_LOG_LEVEL
?
Does it get honored?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added a test for this to ensure the env variable is set. We need ethereum-optimism/optimism#16050 too in order for the tests to be honoring the log level.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But is it used? I don't see where?
// Verify that logs are not captured when OutputTestLogs is disabled | ||
assert.Equal(t, types.TestStatusPass, testResult2.Status) | ||
assert.Contains(t, testResult2.Stdout, "This is a test output") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be asserting that it does NOT contain this output?
// Verify that logs are not captured when OutputTestLogs is disabled | |
assert.Equal(t, types.TestStatusPass, testResult2.Status) | |
assert.Contains(t, testResult2.Stdout, "This is a test output") | |
// Verify that logs are not captured when OutputTestLogs is disabled | |
assert.Equal(t, types.TestStatusPass, testResult2.Status) | |
assert.NotContains(t, testResult2.Stdout, "This is a test output") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually the input is shown either way because we're not saving it to a file, that's what the test itself is testing. I think the other pre-existing tests cover the file logging part so I didn't add for that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm afraid I don't understand. How is this block of code verifying that logs are NOT captured?
// Verify that logs are not captured when OutputTestLogs is disabled
assert.Equal(t, types.TestStatusPass, testResult2.Status)
assert.Contains(t, testResult2.Stdout, "This is a test output")
@@ -68,3 +70,133 @@ gates: | |||
assert.Contains(t, failingTest.Stdout, "This is some stdout output that should be captured") | |||
assert.Contains(t, failingTest.Stdout, "This is a second line of output") | |||
} | |||
|
|||
// TestLogLevelEnvironment verifies that the TEST_LOG_LEVEL environment variable is correctly set and used | |||
func TestLogLevelEnvironment(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's also test the different levels behave differently?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test runner should be parsing the env variable (in the optimism repo) so I'm not sure we need to check the setup here
@@ -9,7 +9,9 @@ COPY op-acceptor/ . | |||
|
|||
RUN just build | |||
|
|||
FROM alpine:3.21 | |||
FROM golang:1.23.5-alpine3.21 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need the runner image to be updated, do we?
@@ -563,10 +601,12 @@ func (r *runner) runSingleTest(ctx context.Context, metadata types.ValidatorMeta | |||
|
|||
// If we couldn't parse the output for some reason, create a minimal failing result | |||
if parsedResult == nil { | |||
r.log.Error("test exited with non-zero exit code", "exitCode", cmd.ProcessState.ExitCode()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is confusing me; it need not necessarily have exited non-zero here?
// Verify that logs are not captured when OutputTestLogs is disabled | ||
assert.Equal(t, types.TestStatusPass, testResult2.Status) | ||
assert.Contains(t, testResult2.Stdout, "This is a test output") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm afraid I don't understand. How is this block of code verifying that logs are NOT captured?
// Verify that logs are not captured when OutputTestLogs is disabled
assert.Equal(t, types.TestStatusPass, testResult2.Status)
assert.Contains(t, testResult2.Stdout, "This is a test output")
Description
Tests
Added a test to verify the paths checks logic.
Additional context
When running the tests sometimes we may want to get extra information on these. Right now we need to ssh into the container, but this PR adds a flag to dump the logs into the console.
Requires ethereum-optimism/optimism#16050 for the test log level.
Metadata